package com.ruoyi.electronicFence.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.electronicFence.domain.PortalDisplay;
import com.ruoyi.electronicFence.service.IPortalDisplayService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 门户展示模块信息表Controller
 *
 * @author ygsj
 * @date 2024-04-10
 */
@RestController
@RequestMapping("/electronicFence/display")
public class PortalDisplayController extends BaseController
{
    @Autowired
    private IPortalDisplayService portalDisplayService;

    /**
     * 查询门户展示模块信息表列表
     */
    @PreAuthorize("@ss.hasPermi('electronicFence:display:list')")
    @GetMapping("/list")
    public TableDataInfo list(PortalDisplay portalDisplay)
    {
        startPage();
        List<PortalDisplay> list = portalDisplayService.selectPortalDisplayList(portalDisplay);
        return getDataTable(list);
    }

    /**
     * 查询门户展示模块信息表列表
     */
//    @PreAuthorize("@ss.hasPermi('electronicFence:display:list')")
    @GetMapping("/list2")
    public TableDataInfo list2(PortalDisplay portalDisplay)
    {
        startPage();
        List<Map> list = portalDisplayService.selectPortalDisplayList2(portalDisplay);
        return getDataTable(list);
    }

    /**
     * 导出门户展示模块信息表列表
     */
    @PreAuthorize("@ss.hasPermi('electronicFence:display:export')")
    @Log(title = "门户展示模块信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PortalDisplay portalDisplay)
    {
        List<PortalDisplay> list = portalDisplayService.selectPortalDisplayList(portalDisplay);
        ExcelUtil<PortalDisplay> util = new ExcelUtil<PortalDisplay>(PortalDisplay.class);
        util.exportExcel(response, list, "门户展示模块信息表数据");
    }

    /**
     * 获取门户展示模块信息表详细信息
     */
    @PreAuthorize("@ss.hasPermi('electronicFence:display:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(portalDisplayService.selectPortalDisplayById(id));
    }

    /**
     * 新增门户展示模块信息表
     */
    @PreAuthorize("@ss.hasPermi('electronicFence:display:add')")
    @Log(title = "门户展示模块信息表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PortalDisplay portalDisplay)
    {
        return toAjax(portalDisplayService.insertPortalDisplay(portalDisplay));
    }

    /**
     * 修改门户展示模块信息表
     */
    @PreAuthorize("@ss.hasPermi('electronicFence:display:edit')")
    @Log(title = "门户展示模块信息表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PortalDisplay portalDisplay)
    {
        return toAjax(portalDisplayService.updatePortalDisplay(portalDisplay));
    }

    /**
     * 删除门户展示模块信息表
     */
    @PreAuthorize("@ss.hasPermi('electronicFence:display:remove')")
    @Log(title = "门户展示模块信息表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(portalDisplayService.deletePortalDisplayByIds(ids));
    }
}
